package com.yisu.expressway.driver_revelation.adapter;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yisu.expressway.R;
import com.yisu.expressway.databinding.ContactListItemBinding;
import com.yisu.expressway.databinding.RevelationTopicListItemBinding;
import com.yisu.expressway.driver_revelation.model.LiveListItemObj;
import com.yisu.expressway.driver_revelation.model.LiveListObj;
import com.yisu.expressway.listener.onClickHandler;
import com.yisu.expressway.more_contact.MoreContactActivity;
import com.yisu.expressway.more_contact.model.ContactModel;
import com.yisu.expressway.utils.PhoneCallUtils;

import java.util.ArrayList;

/**
 * Created by theodore_hu on 2016/12/21 0021.
 */

public class LiveListAdapter extends RecyclerView.Adapter<LiveListAdapter.ContactHolder> {


    @NonNull
    private ArrayList<LiveListObj> mData = new ArrayList<>();
    Context mContext;

    public LiveListAdapter(Context context){
        mContext = context;
    }

    public void updateData(ArrayList<LiveListObj> list){
        mData = list;
        notifyDataSetChanged();
    }

    @Override
    public ContactHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.revelation_topic_list_item, parent, false);
        return new ContactHolder(itemView);
    }

    @Override
    public void onBindViewHolder(ContactHolder holder, int position) {
        holder.bind(mData.get(position));
    }

    @Override
    public int getItemCount() {
        return mData == null ? 0 : mData.size();
    }


    public  class ContactHolder extends RecyclerView.ViewHolder implements onClickHandler  {
        private RevelationTopicListItemBinding itemBinding;

        public ContactHolder(View view){
            super(view);
            itemBinding = DataBindingUtil.bind(view);
        }

        public void bind(@NonNull LiveListObj listItem){
            itemBinding.setLiveItem(listItem);
            itemBinding.setClickListener(this);
        }

        @Override
        public void handleClick(View view) {


        }
    }
}
